From 84592bf97c218c5e8cf6ac9ca120a72692dbe193 Mon Sep 17 00:00:00 2001 From: "cl349@firebug.cl.cam.ac.uk" Date: Mon, 12 Sep 2005 20:24:58 +0000 Subject: [PATCH] Check the return value of chdir(2) and write(2). Signed-off-by: Christian Limpach --- tools/console/daemon/utils.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/console/daemon/utils.c b/tools/console/daemon/utils.c index 985de2061a..3372632737 100644 --- a/tools/console/daemon/utils.c +++ b/tools/console/daemon/utils.c @@ -105,7 +105,8 @@ void daemonize(const char *pidfile) close(fd); umask(027); - chdir("/"); + if (chdir("/") < 0) + exit (1); fd = open(pidfile, O_RDWR | O_CREAT); if (fd == -1) { @@ -117,7 +118,8 @@ void daemonize(const char *pidfile) } len = sprintf(buf, "%d\n", getpid()); - write(fd, buf, len); + if (write(fd, buf, len) < 0) + exit(1); signal(SIGCHLD, child_exit); signal(SIGTSTP, SIG_IGN); -- 2.30.2